package com.lzh.others.designmode.factorymod.simpleFactoryMod;

/**
 * @Description: 简单工厂
 * @Author: LiuZiHao
 * @Date: 2022/11/7 11:53
 */
public class ChartFactory {

    /**
     * 创建图表，负担重，不符合开闭原则
     *
     * @param type
     * @return
     */
    public static IChart create(String type) {
        switch (type) {
            case "bar":
                return new BarChart();
            case "pie":
                return new PieChart();
            case "line":
                return new LineChart();
            default:
                return null;
        }
    }
}
